// import { json } from "stream/consumers";
import { isJSON } from "../../utils/determine";

export class ResponseBody{

    public body: string;
    
    constructor(body: string){
        this.body  = body;
    }

    toBean(){
        return new Promise((resolve,reject)=>{
            if(isJSON(this.body)){
                resolve(JSON.parse(this.body));
            }else{
                reject(this.body);
            }
        });
    }
}